package com.demo.statemachine.d21;

import com.demo.statemachine.d20.TestEvents;
import com.demo.statemachine.d20.TestStates;
import lombok.extern.slf4j.Slf4j;
import org.springframework.statemachine.listener.StateMachineListenerAdapter;
import org.springframework.statemachine.state.State;


@Slf4j
public class TimerListener extends StateMachineListenerAdapter<String, String> {

    @Override
    public void stateEntered(State<String, String> state) {
        StringBuilder stringBuilder = new StringBuilder("");
        state.getStates().forEach(e -> {
            stringBuilder.append(e.getId() + " , ");
        });
        log.info(">>> 进入 {}", stringBuilder.toString());
    }

    @Override
    public void stateExited(State<String, String> state) {
        StringBuilder stringBuilder = new StringBuilder("");
        state.getStates().forEach(e -> {
            stringBuilder.append(e.getId() + " , ");
        });
        log.info("<<<  退出 {}", stringBuilder.toString());
    }
}
